package xyz.xtt.asset.constants;

import java.util.concurrent.TimeUnit;

import xyz.xtt.asset.client.response.NftListVo;
import xyz.xtt.asset.client.response.SecondAssetListVo;
import xyz.xtt.asset.entity.TblArtAmberOrder;
import xyz.xtt.asset.entity.TblAsset;
import xyz.xtt.asset.entity.TblAssetExt;
import xyz.xtt.asset.entity.TblAssetStaticResource;
import xyz.xtt.asset.entity.TblAssetUserLog;
import xyz.xtt.asset.entity.TblAssetsType;
import xyz.xtt.asset.entity.TblBlindBoxDetail;
import xyz.xtt.asset.entity.TblThirdOrder;
import xyz.xtt.asset.response.ArtAmberCardResponse;
import xyz.xtt.asset.vo.AssetTypeItem;
import xyz.xtt.asset.vo.AssetTypeResponseVo;
import xyz.xtt.asset.vo.HomeTopResponse;
import xyz.xtt.asset.vo.QueryCollectionResponseVo;
import xyz.xtt.common.starter.cache.CacheConfig;

/**
 * 缓存类枚举
 * 
 * @author huqibo
 * @date 2024/11/28
 */
public enum AssetCache implements CacheConfig {
	/**
	 * 个人风格明细
	 */
	COLL_QUERY_TYPE("colltype", 1, TimeUnit.DAYS, QueryCollectionResponseVo.class),
	/**
	 * 资产分类
	 */
	ASSET_TYPE("assettype", 1, TimeUnit.DAYS, AssetTypeResponseVo.class),
	/**
	 * 首页
	 */
	HOME_TOP("homeTop", 1, TimeUnit.DAYS, HomeTopResponse.class),
	/**
	 * 资产缓存
	 */
	TBL_ASSET("tblAsset", 1, TimeUnit.DAYS, TblAsset.class),
	/**
	 * 资产缓存
	 */
	TBL_ASSET_BY_ID("tblAssetById", 1, TimeUnit.DAYS, TblAsset.class),
	/**
	 * 资产缓存
	 */
	TBL_ASSET_WITH_ID("tblAssetWithId", 1, TimeUnit.DAYS, TblAsset.class),
	/**
	 * 资产缓存
	 */
	TBL_ASSET_TYPE("tblAssetsType", 1, TimeUnit.DAYS, TblAssetsType.class),
	/**
	 * 资产扩展缓存
	 * 
	 * 缓存key tblAssetExt:{assetId}
	 */
	TBL_ASSET_EXT("tblAssetExt", 1, TimeUnit.DAYS, TblAssetExt.class),
	/**
	 * 资产静态资源缓存
	 */
	TBL_ASSET_STATIC_RESOURCE("tblAssetStaticResource", 1, TimeUnit.DAYS, TblAssetStaticResource.class),
	/**
	 * 资产扩展缓存
	 * 
	 * 缓存key tblAssetExt:{assetId}
	 */
	QUERY_MY_ASSETS("queryMyAssets", 5, TimeUnit.MINUTES, AssetTypeItem.class),
	/**
	 * 艺术卡用户维度缓存
	 */
	QUERY_ART_CARD_WITH_UID("queryArtCardWithUid", 1, TimeUnit.DAYS, ArtAmberCardResponse.class),
	/**
	 * 赠送次数上限
	 */
	GIFT_LIMT_KEY("giftLimit", 1, TimeUnit.DAYS, Long.class),
	/**
	 * 三方订单
	 */
	TBL_THIRD_ORDER("tblThirdOrder", 7, TimeUnit.DAYS, TblThirdOrder.class),
	/**
	 * 艺术卡缓存
	 */
	TBL_ART_AMBER_ORDER("tblArtAmberOrder", 1, TimeUnit.DAYS, TblArtAmberOrder.class),
	/**
	 * 盲盒
	 */
	TBL_BLIND_BOX_DETAIL("tblBlindBoxDetail", 7, TimeUnit.DAYS, TblBlindBoxDetail.class),

	INDEX_LIST("indexList", 1, TimeUnit.MINUTES, NftListVo.class),
	/**
	 * 操作日志, 最后一条
	 */
	TBL_ASSET_USER_LOG("tblAssetUserLog", 1, TimeUnit.DAYS, TblAssetUserLog.class),

	ASSET_CHILDREN("assetChildren", 1, TimeUnit.DAYS, TblAsset.class),

	SECOND_ASSET_LIST("secondAssetList", 1, TimeUnit.DAYS, SecondAssetListVo.class),
	
	;

	/**
	 * 缓存key前缀
	 */
	private String prefix;
	/**
	 * 缓存时长
	 */
	private long ttl;
	/**
	 * 缓存时长单位
	 */
	private TimeUnit timeUnit;
	/**
	 * 缓存序列化对象类型
	 */
	private Class<?> clazz;

	private <T> AssetCache(String prefix, long ttl, TimeUnit timeUnit, Class<T> clazz) {
		this.prefix = prefix;
		this.ttl = ttl;
		this.timeUnit = timeUnit;
		this.clazz = clazz;
	}

	@Override
	public String prefix() {
		return prefix;
	}

	@Override
	public long ttl() {
		return ttl;
	}

	@Override
	public TimeUnit timeUnit() {
		return timeUnit;
	}

	@Override
	public Class<?> clazz() {
		return clazz;
	}

}
